package thread;
/**
 * 第二种创建线程的方式
 * 实现Runnable接口单独定义线程任务
 */
public class ThreadDemo2 {
    public static void main(String[] args) {
        //实例化任务
        Runnable r1 = new Myrunnable1();
        Runnable r2 = new Myrunnable2();
        //2:创建线程将任务交给线程
        Thread t1 = new Thread(r1);
        Thread t2 = new Thread(r2);
        //3:启动线程
        t1.start();
        t2.start();
    }
}

class Myrunnable1 implements Runnable{
    public void run(){
        for (int i = 0; i < 50; i++){
            System.out.println("扣你鸡娃！");
        }
    }

}

class Myrunnable2 implements Runnable{
    public void run(){
        for (int i = 0; i < 50; i++){
            System.out.println("我扣你鸡娃儿！");
        }
    }

}